function bar() {
    console.log(myName);
}

function foo() {
    var myName = 'Jack';
    bar();
}

var myName = 'Lucy';

foo();

// Lucy